# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=wrk
pkgver=4.1.0
pkgrel=1
pkgdesc="wrk is a modern HTTP benchmarking tool"
url="https://github.com/wg/wrk"
# requires -march=i586 to build on x86
arch="x86_64 aarch64"
license="Apache-2.0"
depends=""
depends_dev=""
options="!check" # upstream does not provide tests
makedepends="openssl-dev perl-dev linux-headers luajit-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/wg/wrk/archive/$pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$pkgver

build() {
	cd "$builddir"
	# see https://github.com/wg/wrk/issues/310
	touch buildinf.h
	make -j1 -C "$builddir" \
		WITH_OPENSSL=/usr \
		WITH_LUAJIT=/usr CFLAGS+=$(pkg-config --cflags luajit)
}

package() {
	cd "$builddir"
	mkdir -p "$pkgdir"/usr/bin \
		"$pkgdir"/usr/share/licenses/$pkgname \
		"$pkgdir"/usr/share/doc/$pkgname/scripts

        install -m755 -D $pkgname "$pkgdir"/usr/bin/$pkgname
	install -m644 -D README.md "$pkgdir"/usr/share/doc/$pkgname/
	install -m644 -D LICENSE "$pkgdir"/usr/share/licenses/$pkgname/
	install -m644 -D NOTICE "$pkgdir"/usr/share/doc/$pkgname/
	install -m755 -D scripts/* "$pkgdir"/usr/share/doc/$pkgname/scripts/
}

sha512sums="2c8d05f8e40c3a6234bc1c2862157764532a39046860210fe512c260c2b940e1e3120b831d0721c936c7bca474574600cda1f4c949b53738199d98102e32cb1a  wrk-4.1.0.tar.gz"
